package net.qiqbframework.messaging.intercepting.annotation;


import net.qiqbframework.messaging.Message;
import net.qiqbframework.messaging.intercepting.MessageHandlerInterceptor;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 注释将处理程序标记为仅对处理异常结果感兴趣的其他处理程序的侦听器。
 * 此处理程序方法将在执行常规处理程序后调用，并可能将该处理程序的结果作为参数接收。
 * 仅当此方法的参数与处理的消息和处理程序方法调用的结果的组合匹配时，才会调用处理程序
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@MessageHandlerInterceptor
@ResultHandler(resultType = Exception.class)
public @interface ExceptionHandler {

    /**
     * Defines the type of result this handler needs to be triggered for. Defaults to all {@code Exception}s.
     */
    Class<? extends Exception> resultType() default Exception.class;

    /**
     * Specifies the type of message that can be handled by the member method. Defaults to any {@link Message}.
     */
    Class<? extends Message> messageType() default Message.class;

    /**
     * Specifies the type of message payload that can be handled by the member method. The payload of the message should
     * be assignable to this type. Defaults to any {@link Object}.
     */
    Class<?> payloadType() default Object.class;

}
